//
//  YJTrainOrderTableViewController.swift
//  yuejian
//
//  Created by 闫子夜 on 2017/10/25.
//  Copyright © 2017年 gyy. All rights reserved.
//

import UIKit

class YJOrderTableViewController: UITableViewController {
    var train : YJTrainingModel!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.title = train.trainname as String
        
        NotificationCenter.default.addObserver(self, selector:#selector(YJOrderTableViewController.commit),name:NSNotification.Name(rawValue: "Commit"), object: nil)
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        
    }
    
    override func numberOfSections(in tableView: UITableView) -> Int {
        return 1
        
    }
    
    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 1
    }
    
    
    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        
        var basecell: UITableViewCell = UITableViewCell()
        let cell : OrderDetailCell = tableView.dequeueReusableCell(withIdentifier: "orderDetail", for: indexPath) as! OrderDetailCell
        cell.frame = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.size.width, height: CELLHEIGHT);

        tableView.separatorStyle = UITableViewCellSeparatorStyle.none;

        let imageStr = train.thumb
        let imageURL = URL(string: imageStr! as String)
        cell.trainImageView!.setImageWith(imageURL!, placeholderImage: UIImage(named: "placeHolder"))
        cell.train = self.train
        //培训名称
        cell.trainName.text = "\(train.trainname!)"
        //培训价格
        cell.price.text = "\(train.price!)"
        //推荐指数
        cell.recommand.text = "\(train.recommand!)"
        //课程编号
        cell.shop_id.text = "\(train.train_id!)"
        basecell = cell


        return basecell

    }
    
    
    override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        
        return 300;
    }
    
    func commit() {
        let _ = self.navigationController?.popViewController(animated: true)
    }
    
}

